/*
 * Copyright (c) 2015 LingoChamp Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.liulishuo.filedownloader.util;


import com.oszc.bbhmlibrary.utils.LogUtil;

/**
 * The log printer help to control all logs in FileDownloader.
 * <p>
 */
public class FileDownloadLog {

    public static boolean NEED_LOG = true;

    private static final String TAG = "FileDownloader.";

    public static void e(Object o, Throwable e, String msg, Object... args) {
        if(e!=null) {
            e.printStackTrace();
        }

    }

    public static void e(Object o, String msg, Object... args) {

    }

    public static void i(Object o, String msg, Object... args) {
        LogUtil.info(getTag(o),FileDownloadUtils.formatString(msg, args));
    }

    public static void d(Object o, String msg, Object... args) {

    }

    public static void w(Object o, String msg, Object... args) {
        LogUtil.warn(getTag(o),FileDownloadUtils.formatString(msg, args));
    }

    public static void v(Object o, String msg, Object... args) {
        LogUtil.info(getTag(o),FileDownloadUtils.formatString(msg, args));
    }

    private static String getTag(final Object o) {
        return TAG + ((o instanceof Class)
                ? ((Class) o).getSimpleName() : o.getClass().getSimpleName());
    }

}
